<?php


class Blackbird_Form_Users_ChangePassword extends Zend_Form
{
	function __construct($options = null)
	{
		parent::__construct($options);

		$this
			->addElement('hash', 'csrf')

			->addElement('password', 'currentPassword', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Contraseña actual:',
				'maxlength' => 100,
				'required' => true,
				'validators' => array(array('StringLength', true, array('min' => 1, 'max' => 100))),
			))

			->addElement('password', 'password', array(
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Nueva contraseña / Confirme la contraseña:',
				'maxlength' => 100,
				'required' => true,
				'validators' => array(array('StringLength', true, array('min' => 1, 'max' => 100))),
			))

			->addElement('password', 'confirmPassword', array(
				'filters' => array('StripTags', 'StringTrim'),
				'maxlength' => 100,
				'required' => true,
				'validators' => array(array('StringLength', true, array('min' => 1, 'max' => 100))),
			))

			->addElement('button', 'submit', array(
				'label' => 'Cambiar contraseña',
				'ignore' => true,
				'type' => 'submit',
			))

			->addElement('button', 'cancel', array(
				'label' => 'Cancelar',
				'ignore' => true,
				'type' => 'button',
				'onclick' => 'history.go(-1)',
			))
			;

		$this->password
			->addDecorator('HtmlTag', array(
				'tag' => 'dd',
				'openOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::PREPEND,
			));
		$this->confirmPassword
			->removeDecorator('Label')
			->addDecorator('HtmlTag', array(
				'closeOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::APPEND,
				'tag' => 'dd',
			));

		$this->submit
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'class' => 'buttons',
				'openOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::PREPEND,
				'tag' => 'dd',
			));

		$this->cancel
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'closeOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::APPEND,
				'tag' => 'dd',
			));

		$this->csrf
			->removeDecorator('DtDdWrapper')
			->removeDecorator('Label');
	}
}

